#!/usr/bin/perl -w
use strict;
use HTML::Entities;
#Copyright 2011. Jason Weirather.
#This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License v3 or any later version.
open(FH,"template_site.html") or die "no file.\n";
chomp(my @lines = <FH>);
close FH;
my $base = shift @ARGV;
my $evalue = shift @ARGV;
my $ivaluestring = shift @ARGV;
open(FH,"work/$base.title") or die "no file.\n";
chomp(my @title = <FH>);
my $title = shift(@title);
close FH;
$title =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;
if($ivaluestring ne "NOVALUE") { $evalue .= " $ivaluestring"; }
foreach my $line (@lines) {
  $line =~ s/FILETITLEgtt/$title/g;
  $line =~ s/FILEEVALUEgtt/$evalue/g;
  $line =~ s/123abcd/$base/g;
  print "$line\n";
}
